$(function(){
	//机场自动补全
	$(".airport").bindAutoComplete({
		url: $path + "/mc/airportshowFilterList?a=" + Math.random(),
		searchKey: "filterStr", 
		beShowedItem: function(content, item) {
			if(content != "") {
				//如果是多选的情况，截取最后输入的内容
				if(content.indexOf(",") !== -1) {
					content = content.substring(content.lastIndexOf(",") + 1);
				}
				if((/^[\u4E00-\u9FA5]+$/).test(content)) {
					//输入了中文的情况
					content = item.fairportName;
				} else {
					//输入了英文的情况
					content = item.icaoCode;
				}
			}
			return content;
		}
	});
	
	//补全员工号（江健斌）
	$(".statff").bindAutoComplete({
		url: $path + "/mc/userNPchoiceStatff?a=" + Math.random(),
		data: null,
		searchKey: "staffNumStr",
		multiple: false,
		beShowedItem: function(content, item) {
			if(content != "") {
				content = item.name;
			 }
			return content;
		},
		beChoosedItem: function(content, item) {
			return item.staffNum;
		}
	});
	
	//补全员工号多个选（江健斌）
	$(".statffs").bindAutoComplete({
		url: $path + "/mc/userNPchoiceStatff?a=" + Math.random(),
		data: null,
		searchKey: "staffNumStr",
		multiple: true,
		beShowedItem: function(content, item) {
			if(content != "") {
				content = item.name;
			 }
			return content;
		},
		beChoosedItem: function(content, item) {
			return item.staffNum;
		}
	});
	
	//机尾号自动补全
	$(".tailNum").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/tairCraftshowAirCraftList?a=" + Math.random(),
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.tailNum;
			}
			return content;
		}
	});
	
	//机尾号自动补全带参数（过滤机型）
	$(".tailNumArgs").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: function() {
			//稳态巡航数据页面获取已选性能机型
			var flatestEqpCdOne = $(".steadyDataSearch #flatestEqpCdOneArray").val();
			return $path + "/mc/tairCraftshowAirCraftArgsList?planeModelListStr="+flatestEqpCdOne+"&a=" + Math.random();
		},
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.tailNum;
			}
			return content;
		}
	});
	
	//机尾号自动补全带参数（过滤机型）
	$(".tailNumArgs1").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: function() {
			//稳态巡航数据页面获取已选性能机型
			var flatestEqpCdOne = $("#performanceForm #flatestEqpCdOneArrayForPerformance").val();
			return $path + "/mc/tairCraftshowAirCraftArgsList?planeModelListStr="+flatestEqpCdOne+"&a=" + Math.random();
		},
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.tailNum;
			}
			return content;
		}
	});
	
	//机型自动补全
	$(".fmAuto").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airCraftModelshowAcLatestEqpCdFmList?a=" + Math.random(),
		searchKey: 'latestEqpCdFm',
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.latestEqpCdFm;
			}
			return content;
		}
	});
	
	//动态机型自动补全
	$(".fmAutoDynamic").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airCraftModelshowDynamicLatestEqpCdList?a=" + Math.random(),
		searchKey: 'latestEqpCd',
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.latestEqpCd;
			}
			return content;
		}
	});
	
	//动态机型自动补全
	$(".latestEqpCdOne").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airCraftModelshowLatestEqpCdOneList?a=" + Math.random(),
		searchKey: 'latestEqpCdOne',
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.flatestEqpCdOne;
			}
			return content;
		}
	});
	
	//运品分析机型自动补全
	$(".latestEqpCdFmAny").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airCraftModelshowLatestEqpCdFmAnyList?a=" + Math.random(),
		searchKey: 'latestEqpCdFmAny',
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.latestEqpCdFmAny;
			}
			return content;
		}
	});
	
	//机场三字吗自动补全
	$(".arpCdairport").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airportshowarpCdAirportList?a=" + Math.random(),
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.arpCd;
			}
			return content;
		}
	});
	
	//机场三字吗自动补全
	$(".icaoCodeairport").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airportshowicaoCodeAirportList?a=" + Math.random(),
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.icaoCode;
			}
			return content;
		}
	});
	
	//机场区域自动补全
	$(".areaAirport").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/airportshowAreaAirportList?a=" + Math.random(),
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.area;
			}
			return content;
		}
	});
	
	//签派员英文名自动补全
	$(".dispatcher").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/dispatchershowDispatcherList?a=" + Math.random(),
		beShowedItem: function(content, item) {
			if(content !== "") {
				content = item.surName;
			}
			return content;
		}
	});
	
	//人员自动补全(没有过滤权限)
	$(".npStaffs").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/userNPshowStaffs?a=" + Math.random(),
		searchKey: 'staffNumStr',
		beShowedItem: function(content, item) {
			if(content != "") {
				content = item.name;
			}
			return content;
		},
		beChoosedItem: function(content, item) {
			return item.staffNum;
		}
	});
	
	//飞行员自动补全(有过滤权限)
	$(".pilots, .singlePilot").bindAutoComplete({
		//根据触发控件的类来控件是单选还是多选
		multiple: function(ele) {
			return ele.hasClass("pilots");
		},
		isScrollBottom: true,
		url: $path + "/mc/usershowFlyList?a=" + Math.random(),
		searchKey: 'staffMsgs',
		beShowedItem: function(content, item) {
			if(content != "") {
				content = item.name;
			}
			return content;
		},
		beChoosedItem: function(content, item) {
			return item.name;
		}
	});
	
	//公司自动补全(不过滤权限)
	$(".mulCompany").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/usershowCompanyList?a=" + Math.random(),
		searchKey: 'companyMsgs',
		resListName: 'mulCompanyList' //返回结果集属性名
	});
	
	//公司自动补全(有过滤权限)
	$(".mulCompanyByAuth").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/usershowCompanyList?a=" + Math.random(),
		searchKey: 'companyMsgs',
		resListName: 'mulCompanyList', //返回结果集属性名
		data:{'isShowCompanyByAuth' : true}
	});
	
	//事件代码自动补全
	$(".evtNumAuto").bindAutoComplete({
		multiple: true,
		isScrollBottom: true,
		url: $path + "/mc/evtPraStandardshowAutoCompleteMap?a=" + Math.random(),
		searchKey: 'evtNumStr',
		resListName: 'evtNumAutoCompleteMapList', 
		beShowedItem: function(content, item) {
			if(content != "") {
				content = item.value;
			}
			return content;
		},
		beChoosedItem: function(content, item) {
			return item.key;
		}
	});
});